#include <stdio.h>
#include <stdlib.h>


void insertion_sort(int nums[] ,int n)
{
    int i ,temp;
    int flag = 0;
    for(i=1; i<n; i++)
    {
        int j = i - 1;
        temp = nums[i];
        while(j>=0 && nums[j]>temp)
        {
            nums[j+1] = nums[j];
            j--;
            
        }
        nums[j+1]=temp;
    }
}




int main()
{
    //int n = 8;
    int arr[] = {2,3,1,5,4,8,2,4};
    int n = sizeof(arr)/4;
    int i = 0;
    for(i=0; i<n; i++)
    {
        printf("arr[%d]=%d\n",i,arr[i]);
    }
    printf("arr nums = %d\n",n);
    insertion_sort(arr, n);
    for(i=0; i<n; i++)
    {
        printf("arr[%d]=%d\n",i,arr[i]);
    }


}